/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.manage.repository.mapper;

import info.peigen.hotpot.business.account.core.repository.entity.AccountEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlManageMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

/**
 * <b>(AccountManageMapper)</b>
 * 管理后台 "账户" 数据库映射服务
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-08-29
 */
@SuppressWarnings("unused")
public interface AccountManageMapper extends AbstractBeetlSqlManageMapper<AccountEntity> {

    // 索引[customer_id]
    @Sql("select * from account where customer_id = ?")
    @Select
    AccountEntity findByCustomerId(String customerId);

    @Sql("delete from account where customer_id = ?")
    @Update
    void deleteByCustomerId(String customerId);

    // 唯一索引[account_id]
    @Sql("select * from account where account_id = ?")
    @Select
    AccountEntity findByAccountId(String accountId);

    @Sql("select * from account where account_id = ? for update")
    @Select
    AccountEntity lockByAccountId(String accountId);

    @Sql("delete from account where account_id = ?")
    @Update
    void deleteByAccountId(String accountId);

    // 索引[account_type]
    @Sql("select * from account where account_type = ?")
    @Select
    AccountEntity findByAccountType(String accountType);

    @Sql("delete from account where account_type = ?")
    @Update
    void deleteByAccountType(String accountType);

    // 索引[status]
    @Sql("select * from account where status = ?")
    @Select
    AccountEntity findByStatus(String status);

    @Sql("delete from account where status = ?")
    @Update
    void deleteByStatus(String status);

    // 索引[currency]
    @Sql("select * from account where currency = ?")
    @Select
    AccountEntity findByCurrency(String currency);

    @Sql("delete from account where currency = ?")
    @Update
    void deleteByCurrency(String currency);

    // 索引[channel_code]
    @Sql("select * from account where channel_code = ?")
    @Select
    AccountEntity findByChannelCode(String channelCode);

    @Sql("delete from account where channel_code = ?")
    @Update
    void deleteByChannelCode(String channelCode);

    // 索引[partner_id]
    @Sql("select * from account where partner_id = ?")
    @Select
    AccountEntity findByPartnerId(String partnerId);

    @Sql("delete from account where partner_id = ?")
    @Update
    void deleteByPartnerId(String partnerId);
}